package com.datapermission.thread;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;

@Configuration
public class ThreadPoolConfig {

    @Bean
    public CustomThreadPoolExecutor customThreadPoolExecutor() {
        // 配置线程池参数：核心线程数、最大线程数、线程空闲保持时间、任务队列
        return new CustomThreadPoolExecutor(
                10,  // 核心线程数
                20,  // 最大线程数
                60L, // 空闲线程存活时间
                TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(100) // 任务队列
        );
    }
}
